Skip to content

feat(HikVision): integrate WebRTC preview with MediaMTX - #1389

Merged
ArgoZhang merged 20 commits into
masterfrom
dev-hikvison
Dec 2, 2026
Merged

ArgoZhang merged 20 commits into
masterfrom
dev-hikvison

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1388

Summary By Copilot

  • Replace the direct WebRtcUrl parameter with MediaMtxCameraOptions; on first interactive render, start the MediaMTX gateway and register the camera before displaying its player URL.
  • Add cancellation-aware initialization and disposal, error logging, localized loading/missing-tool/start/registration/invalid-URL states, and preserve the existing mute-query behavior.
  • Update BootstrapBlazor.HikVision to 11.0.3, reference BootstrapBlazor.MediaMtx 11.0.1, mark the package as server-hosted rather than browser-supported, and embed the new locale resources.
  • Add HikVision setup and deployment documentation and update the bundled bb-hikvision skill; adjust related component documentation.

Regression?

  • Yes
  • No

The component API changes from WebRtcUrl to Options, so applications using the 11.0.2 API must migrate. This is an intentional change for the new server-side MediaMTX integration.

Risk

  • High
  • Medium
  • Low

The change affects a public component parameter and adds a server-side service dependency; existing direct-URL callers require migration, and this component is no longer suitable for standalone WebAssembly hosting.

Verification

  • Manual (required)
  • Automated

Builds, tests, package generation, and browser playback checks were not run as required by the Issue/PR creation skill.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

Reviewed the package version, MediaMTX package reference, browser platform exclusion, and embedded locale resources. Package generation/installation was not tested.

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

The new README includes a server-side usage example, so a separate demo change was not needed. The branch includes the latest master commit (a05389a4).

Summary by Sourcery

Integrate HikVision WebRTC preview with MediaMTX camera registration and update the package contract for server-hosted use.

New Features:

  • Integrate HikVision WebRTC preview with the server-side MediaMTX service, registering camera options before displaying the player and showing localized loading and failure states.

Bug Fixes:

  • Correct HikVision channel model and component API documentation that described channel types and capture behavior inaccurately.

Enhancements:

  • Replace the public WebRTC player URL parameter with MediaMTX camera options; existing callers must migrate, and camera options are applied only during the first interactive render.

Build:

  • Update the HikVision package version and add a dependency on BootstrapBlazor.MediaMtx; exclude the package from browser-only hosting and embed English and Chinese locale resources.

Deployment:

  • Document server-side MediaMTX service registration and deployment of its native tools; clarify that the integrated preview requires a process-capable server host.

Documentation:

  • Add HikVision setup and usage documentation and update the bundled HikVision skill with the MediaMTX integration and current component behavior.

@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Replace the WebRTC component’s direct player-URL parameter with camera options and inject the MediaMTX service, changing the public integration contract.

  • src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs L20-25, L36-37, L43-51

Clarify the HikVision WebSDK component’s public login, channel callback, capture, and window-layout behavior.

  • src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs L40-422 (7 small edits)

Implementation

Initialize the MediaMTX gateway and register the camera on first interactive render, handle failures and cancellation, then construct and validate the player URL and cancel outstanding work on disposal.

  • src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs L62-155, L170-185 (+2 small edits)

UI

Render localized missing-options, initialization, failure, and invalid-URL states, and show the iframe only when a player URL is available.

  • src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor L4-40

Configuration

Update the HikVision package’s MediaMTX dependency, package version, platform support, and locale resource embedding configuration.

  • src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj L1-4, L15-19, L26-30 (+1 small edits)

Documentation

Add package setup, server-side WebRTC deployment, security, and WebSDK usage guidance in the README.

  • src/components/BootstrapBlazor.HikVision/README.HikVision.md L1-60

Revise the bundled skill reference to describe the new MediaMTX-backed component contract, operational behavior, and deployment guidance.

  • src/components/BootstrapBlazor.HikVision/skills/bb-hikvision/SKILL.md L13-33, L44-86 (+3 small edits)

Correct the XML documentation for digital and zero-channel model types.

  • src/components/BootstrapBlazor.HikVision/Components/HikVisionChannel.cs L23
  • src/components/BootstrapBlazor.HikVision/Components/HikVisionDigitalChannel.cs L8
  • src/components/BootstrapBlazor.HikVision/Components/HikVisionZeroChannel.cs L8

Lock files and vendored code

Add English and Chinese localized strings for the WebRTC component’s status and error states.

  • src/components/BootstrapBlazor.HikVision/Locales/en.json L1-11
  • src/components/BootstrapBlazor.HikVision/Locales/zh.json L1-11

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added the enhancement New feature or request label Dec 2, 2026
@bb-auto bb-auto Bot added this to the v11.0.0 milestone Dec 2, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit 3e414a2 into master Dec 2, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the dev-hikvison branch December 2, 2026 01:32
@sourcery-ai

sourcery-ai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit ad7fce7

#1388 feat(HikVision): integrate WebRTC preview with MediaMTX · 6 of 6 met

# Requirement Status Notes
1 Accept MediaMtxCameraOptions and replace the WebRtcUrl contract ✅ Met HikVisionWebRtc exposes Options, and the README, skill, and XML documentation describe the migration.
2 Start the gateway and register or update the camera on first interactive render before displaying the player URL ✅ Met OnAfterRenderAsync runs the service calls only on firstRender and assigns the registered URL before rendering the iframe.
3 Show localized status and failure messages ✅ Met The component uses localized messages for missing options, initialization, missing tools, gateway and registration failures, and invalid URLs; English and Chinese resources are embedded.
4 Document server-side registration and MediaMTX tool deployment requirements ✅ Met README.HikVision.md documents AddMediaMtxService, server-hosted usage, and separate deployment of the native tools.
5 Do not download tools or initialize during prerender ✅ Met The component calls the service from OnAfterRenderAsync and contains no tool-download logic; the README states that prerender does not start the gateway.
6 Describe the server-hosted limitation and that options are not re-registered after the first render ✅ Met The project excludes the browser platform, and the README and skill document the host limitation and first-render-only registration.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 8 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="139" />
<code_context>
+        string? registeredUrl = null;
+        try
+        {
+            registeredUrl = await MediaMtxService.AddOrUpdateAsync(options, cancellationToken);
+            cancellationToken.ThrowIfCancellationRequested();
+        }
</code_context>
<issue_to_address>
**Camera streams lack reader authorization**

When the MediaMTX listener is reachable through a reverse proxy or other network route that does not enforce authentication, the registered camera is served through MediaMTX, whose generated configuration grants `read` permission to user `any`. An unauthenticated visitor who can reach the gateway or an unauthenticated reverse proxy can view streams by path, bypassing authorization on the page that renders this component.

Require authorization at the MediaMTX reader or reverse-proxy boundary before exposing camera streams, and document that page authorization alone does not protect the iframe endpoint.
</issue_to_address>

### Comment 2
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="139" />
<code_context>
+        string? registeredUrl = null;
+        try
+        {
+            registeredUrl = await MediaMtxService.AddOrUpdateAsync(options, cancellationToken);
+            cancellationToken.ThrowIfCancellationRequested();
+        }
</code_context>
<issue_to_address>
**Camera options enable server-side SSRF**

When an application lets an untrusted user choose or modify the component's `Options`, `RegisterUrl` passes the supplied camera options to the server-side MediaMTX service, which accepts any absolute RTSP/RTSPS host and lets MediaMTX connect to it. A user who can influence those options can make the application server connect to internal or otherwise restricted RTSP services.

Validate the RTSP destination against a server-side allowlist or equivalent network policy before registering it, and prevent access to loopback, link-local, and other restricted destinations.
</issue_to_address>

### Comment 3
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="25" />
<code_context>
     /// </summary>
     [Parameter]
-    public string? WebRtcUrl { get; set; }
+    public MediaMtxCameraOptions? Options { get; set; }

     /// <summary>
</code_context>
<issue_to_address>
**Existing consumers stop compiling**

When an application upgrades from 11.0.2 while still passing `WebRtcUrl`, `HikVisionWebRtc` no longer exposes `WebRtcUrl`, so existing Razor or C# usages fail to compile instead of working as a patch upgrade.

Keep `WebRtcUrl` compatible, or make its removal in a major release.

Also at `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs:26`.
</issue_to_address>

### Comment 4
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="155" />
<code_context>
     private Uri? GetPlayerUrl()
     {
-        if (!Uri.TryCreate(WebRtcUrl, UriKind.Absolute, out var url) ||
+        if (!Uri.TryCreate(Options?.PlayUrl ?? _registeredUrl, UriKind.Absolute, out var url) ||
             url.Scheme is not ("http" or "https") || url.UserInfo.Length != 0)
         {
</code_context>
<issue_to_address>
**Preview switches to unregistered camera**

When the parent changes `Options.PlayUrl` after initial registration, including while gateway startup is awaited, `GetPlayerUrl` reads the latest `Options.PlayUrl`, while registration uses the options captured during initialization, so the iframe points to a source that is not registered and the preview shows the wrong camera or fails.

Register the updated options when they change, or have the iframe use only the URL corresponding to the registered options.
</issue_to_address>

### Comment 5
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="139" />
<code_context>
+        string? registeredUrl = null;
+        try
+        {
+            registeredUrl = await MediaMtxService.AddOrUpdateAsync(options, cancellationToken);
+            cancellationToken.ThrowIfCancellationRequested();
+        }
</code_context>
<issue_to_address>
**Closed previews leave registrations**

When a preview component is removed after registering a path that is not intended to remain available, each successful `RegisterUrl` call adds or updates a path in the shared gateway, but disposing the component only cancels pending work and never calls `RemoveAsync`; applications that create previews for transient or changing paths leave stale path configuration and its source credentials active until explicitly removed or the gateway stops.

Define ownership and cleanup semantics for component-created registrations, such as an explicit opt-in cleanup policy or a documented caller-managed registration lifecycle.
</issue_to_address>

### Comment 6
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="92" />
<code_context>
+            var started = await TryEnsureStartedAsync(cancellationToken);
+            if (started)
+            {
+                _registeredUrl = await RegisterUrl(options, cancellationToken);
+            }
+        }
</code_context>
<issue_to_address>
**Restart leaves preview failed**

When a component's startup check returns just before the gateway exits, and another component restarts it while the first proceeds to register, `RegisterUrl` calls `AddOrUpdateAsync` during the restart gap; the service has cleared its API password, so registration throws. `RegisterUrl` catches the exception and leaves `_registeredUrl` null, and this first-render-only initialization then displays a registration error even after the gateway recovers.

Coordinate registration with gateway restart, or retry startup and registration when the service reports that the gateway is not running.
</issue_to_address>

### Comment 7
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="148" />
<code_context>
+        }
+        catch (Exception ex)
+        {
+            Log.LogError(ex, "Failed to register the camera for WebRTC preview. Check the camera path and RTSP URL.");
+        }
+        return registeredUrl;
</code_context>
<issue_to_address>
**Invalid URLs show registration error**

When the default MediaMTX service receives an invalid `Options.PlayUrl`, `RegisterUrl` catches the service exception and leaves `_registeredUrl` null, so the markup shows `RegistrationFailedText` before checking `PlayerUrl` and users see a registration error instead of the invalid-URL message.

Preserve or set the invalid-URL failure state when registration rejects `PlayUrl`, and render that message instead of the generic registration error.

Also at `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor:17`.
</issue_to_address>

### Comment 8
<location path="src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs" line_range="134" />
<code_context>
+        return started;
+    }
+
+    private async Task<string?> RegisterUrl(MediaMtxCameraOptions options, CancellationToken cancellationToken)
+    {
+        string? registeredUrl = null;
</code_context>
<issue_to_address>
**Async helper misses naming suffix**

The private `RegisterUrl` method is asynchronous but lacks the `Async` suffix, so it violates the repository’s naming convention for async methods.

Rename `RegisterUrl` to `RegisterUrlAsync` and update its call site.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

string? registeredUrl = null;
try
{
registeredUrl = await MediaMtxService.AddOrUpdateAsync(options, cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Camera streams lack reader authorization

When the MediaMTX listener is reachable through a reverse proxy or other network route that does not enforce authentication, the registered camera is served through MediaMTX, whose generated configuration grants read permission to user any. An unauthenticated visitor who can reach the gateway or an unauthenticated reverse proxy can view streams by path, bypassing authorization on the page that renders this component.

Require authorization at the MediaMTX reader or reverse-proxy boundary before exposing camera streams, and document that page authorization alone does not protect the iframe endpoint.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 139:

**Camera streams lack reader authorization**

When the MediaMTX listener is reachable through a reverse proxy or other network route that does not enforce authentication, the registered camera is served through MediaMTX, whose generated configuration grants `read` permission to user `any`. An unauthenticated visitor who can reach the gateway or an unauthenticated reverse proxy can view streams by path, bypassing authorization on the page that renders this component.

Require authorization at the MediaMTX reader or reverse-proxy boundary before exposing camera streams, and document that page authorization alone does not protect the iframe endpoint.

string? registeredUrl = null;
try
{
registeredUrl = await MediaMtxService.AddOrUpdateAsync(options, cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Camera options enable server-side SSRF

When an application lets an untrusted user choose or modify the component's Options, RegisterUrl passes the supplied camera options to the server-side MediaMTX service, which accepts any absolute RTSP/RTSPS host and lets MediaMTX connect to it. A user who can influence those options can make the application server connect to internal or otherwise restricted RTSP services.

Validate the RTSP destination against a server-side allowlist or equivalent network policy before registering it, and prevent access to loopback, link-local, and other restricted destinations.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 139:

**Camera options enable server-side SSRF**

When an application lets an untrusted user choose or modify the component's `Options`, `RegisterUrl` passes the supplied camera options to the server-side MediaMTX service, which accepts any absolute RTSP/RTSPS host and lets MediaMTX connect to it. A user who can influence those options can make the application server connect to internal or otherwise restricted RTSP services.

Validate the RTSP destination against a server-side allowlist or equivalent network policy before registering it, and prevent access to loopback, link-local, and other restricted destinations.

/// </summary>
[Parameter]
public string? WebRtcUrl { get; set; }
public MediaMtxCameraOptions? Options { get; set; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Existing consumers stop compiling

When an application upgrades from 11.0.2 while still passing WebRtcUrl, HikVisionWebRtc no longer exposes WebRtcUrl, so existing Razor or C# usages fail to compile instead of working as a patch upgrade.

Keep WebRtcUrl compatible, or make its removal in a major release.

Also at src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs:26.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 25:

**Existing consumers stop compiling**

When an application upgrades from 11.0.2 while still passing `WebRtcUrl`, `HikVisionWebRtc` no longer exposes `WebRtcUrl`, so existing Razor or C# usages fail to compile instead of working as a patch upgrade.

Keep `WebRtcUrl` compatible, or make its removal in a major release.

Also at `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs:26`.

From docs/agents/component-checklist.md L5:

保留已有调用方式和所支持框架的行为。

private Uri? GetPlayerUrl()
{
if (!Uri.TryCreate(WebRtcUrl, UriKind.Absolute, out var url) ||
if (!Uri.TryCreate(Options?.PlayUrl ?? _registeredUrl, UriKind.Absolute, out var url) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Preview switches to unregistered camera

When the parent changes Options.PlayUrl after initial registration, including while gateway startup is awaited, GetPlayerUrl reads the latest Options.PlayUrl, while registration uses the options captured during initialization, so the iframe points to a source that is not registered and the preview shows the wrong camera or fails.

Register the updated options when they change, or have the iframe use only the URL corresponding to the registered options.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 155:

**Preview switches to unregistered camera**

When the parent changes `Options.PlayUrl` after initial registration, including while gateway startup is awaited, `GetPlayerUrl` reads the latest `Options.PlayUrl`, while registration uses the options captured during initialization, so the iframe points to a source that is not registered and the preview shows the wrong camera or fails.

Register the updated options when they change, or have the iframe use only the URL corresponding to the registered options.

string? registeredUrl = null;
try
{
registeredUrl = await MediaMtxService.AddOrUpdateAsync(options, cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Closed previews leave registrations

When a preview component is removed after registering a path that is not intended to remain available, each successful RegisterUrl call adds or updates a path in the shared gateway, but disposing the component only cancels pending work and never calls RemoveAsync; applications that create previews for transient or changing paths leave stale path configuration and its source credentials active until explicitly removed or the gateway stops.

Define ownership and cleanup semantics for component-created registrations, such as an explicit opt-in cleanup policy or a documented caller-managed registration lifecycle.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 139:

**Closed previews leave registrations**

When a preview component is removed after registering a path that is not intended to remain available, each successful `RegisterUrl` call adds or updates a path in the shared gateway, but disposing the component only cancels pending work and never calls `RemoveAsync`; applications that create previews for transient or changing paths leave stale path configuration and its source credentials active until explicitly removed or the gateway stops.

Define ownership and cleanup semantics for component-created registrations, such as an explicit opt-in cleanup policy or a documented caller-managed registration lifecycle.

var started = await TryEnsureStartedAsync(cancellationToken);
if (started)
{
_registeredUrl = await RegisterUrl(options, cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Restart leaves preview failed

When a component's startup check returns just before the gateway exits, and another component restarts it while the first proceeds to register, RegisterUrl calls AddOrUpdateAsync during the restart gap; the service has cleared its API password, so registration throws. RegisterUrl catches the exception and leaves _registeredUrl null, and this first-render-only initialization then displays a registration error even after the gateway recovers.

Coordinate registration with gateway restart, or retry startup and registration when the service reports that the gateway is not running.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 92:

**Restart leaves preview failed**

When a component's startup check returns just before the gateway exits, and another component restarts it while the first proceeds to register, `RegisterUrl` calls `AddOrUpdateAsync` during the restart gap; the service has cleared its API password, so registration throws. `RegisterUrl` catches the exception and leaves `_registeredUrl` null, and this first-render-only initialization then displays a registration error even after the gateway recovers.

Coordinate registration with gateway restart, or retry startup and registration when the service reports that the gateway is not running.

}
catch (Exception ex)
{
Log.LogError(ex, "Failed to register the camera for WebRTC preview. Check the camera path and RTSP URL.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Invalid URLs show registration error

When the default MediaMTX service receives an invalid Options.PlayUrl, RegisterUrl catches the service exception and leaves _registeredUrl null, so the markup shows RegistrationFailedText before checking PlayerUrl and users see a registration error instead of the invalid-URL message.

Preserve or set the invalid-URL failure state when registration rejects PlayUrl, and render that message instead of the generic registration error.

Also at src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor:17.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 148:

**Invalid URLs show registration error**

When the default MediaMTX service receives an invalid `Options.PlayUrl`, `RegisterUrl` catches the service exception and leaves `_registeredUrl` null, so the markup shows `RegistrationFailedText` before checking `PlayerUrl` and users see a registration error instead of the invalid-URL message.

Preserve or set the invalid-URL failure state when registration rejects `PlayUrl`, and render that message instead of the generic registration error.

Also at `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor:17`.

return started;
}

private async Task<string?> RegisterUrl(MediaMtxCameraOptions options, CancellationToken cancellationToken)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Low · Async helper misses naming suffix

The private RegisterUrl method is asynchronous but lacks the Async suffix, so it violates the repository’s naming convention for async methods.

Rename RegisterUrl to RegisterUrlAsync and update its call site.

Prompt for AI agents
In `src/components/BootstrapBlazor.HikVision/Components/HikVisionWebRtc.razor.cs` at line 134:

**Async helper misses naming suffix**

The private `RegisterUrl` method is asynchronous but lacks the `Async` suffix, so it violates the repository’s naming convention for async methods.

Rename `RegisterUrl` to `RegisterUrlAsync` and update its call site.

From AGENTS.md L18:

- **C#**。遵循 `.editorconfig` 和相邻文件的风格,优先使用文件范围命名空间,添加源文件时沿用文件头。源码启用可空引用类型和隐式 `using`。处理无效输入或已释放状态时可用早期返回,新增异步方法优先用 `Async` 后缀,保留已有公开签名和接口约定。[编辑器配置](.editorconfig) · [共享构建属性](Directory.Build.props)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(HikVision): integrate WebRTC preview with MediaMTX

1 participant